/-app
TopLayout.ts
main.css
start.ts
/-docs
/-docs/types
text.ts
api.ts
/-files ...
FileTree.ts
SyncStorageAccess.ts
/-imports
/-storage
/-typings
errors.js
functions.ts
index.html
try.js
xxxxxxxxxx
 
86
      else {
87
        var ul = arg1;
88
        this.name = '';
89
        this.fullPath = '';
90
        this._ul = ul;
91
        this._li = null;
92
      }
93
                 
94
      if (this._ul) {
95
        this._children = [];
96
        for (var i = 0; i < this._ul.children.length; i++) {
97
         var childLI = <HTMLLIElement>this._ul.children.item(i);
98
         if (childLI.tagName === 'LI'
99
          || (childLI.tagName && childLI.tagName.toLowerCase() === 'li')) {
100
           var childNode = new Node(this.fullPath, childLI);
101
           this._children.push(childNode);
102
         }
103
        }
104
      }
105
    }
106
    
107
    read(): { [propertyName: string]: string; } {
108
      this._populatePropertyCache();
109
      var result: { [propertyName: string]: string; } = {};
110
      for (var k in this._propertyElementCache) if (this._propertyElementCache.hasOwnProperty(k)) {
111
        var elem = this._propertyElementCache[k];
112
        result[k] = decodeFromInnerHTML(elem.textContent);
113
      }
114
      
115
      return result;
116
    }
117
​
118
    update(values: { [propertyName: string]: string; }): void {
119
      for (var propertyName in values) if (values.hasOwnProperty(propertyName)) {
120
        propertyName = propertyName || null;
121
        var elem = this._propertyElementCache[propertyName];
122
        if (!elem) {
123
          elem = document.createElement('pre');
124
          elem.className = 'data-teapo-property';
125
          this._propertyElementCache[propertyName] = elem;
126
        }
127
        elem.textContent = encodeForInnerHTML(values[propertyName]);
128
      }
129
    }
130
​
131
    getNode(path: string, createIfAbsent: boolean): Node {
132
​
133
      if (!this._ul)
134
        throw new Error('Node is not a directory.');
135
      
136
      var name: string, restPath: string;
137
      
138
      var slashPos = path.indexOf('/');
139
      while (!slashPos) { // slight normalization, keep it for the sake of root paths
140
          path = path.slice(1);
141
          slashPos = path.indexOf('/');
142
      }
143
​
144
      if (slashPos < 0) {
145
          name = path;
146
          restPath = null;
147
      }
148
      else {
149
          name = path.slice(0, slashPos);
150
          restPath = path.slice(slashPos + 1);
151
      }
152
​
153
      return this._getNodeCore(name, restPath, createIfAbsent);
154
    }
155
​
156
    private _populatePropertyCache() {
157
      if (this._propertyElementCache) return;
158
      
159
      this._propertyElementCache = {};
160
      for (var i = 0; i < this._li.children.length; i++) {
161
        var elem = <HTMLPreElement>this._li.children.item(i);
162
        if (elem.tagName === 'PRE'
163
          || (elem.tagName !== 'UL' && elem.tagName && elem.tagName.toLowerCase() == 'pre')) {
164
          var propertyName = elem.getAttribute('data-teapo-property') || null;
165
          this._propertyElementCache[propertyName] = elem;
166
        }
126:68